package com.cskaoyan.gateway.Utils;

import com.mall.commons.tool.utils.CookieUtil;
import com.mall.user.IAddressService;
import org.apache.catalina.security.SecurityUtil;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

/**
 * @author hsp
 * @date 2021/5/25 17:19
 */
@Component
public class MallUtil {
    @Reference(timeout = 3000,check = false)
    IAddressService iAddressService;

    public Long getUserIdByRequest(HttpServletRequest request){

        String token = CookieUtil.getCookieValue(request, "access_token");

        Long userIdByToken = iAddressService.getUserIdByToken(token);
        return userIdByToken;
    }
}
